package com.sky.wsp.mybatis.plus.utils;

import com.sky.wsp.mybatis.plus.interceptor.UserSessionVO;

import java.util.List;

/**
 * @author wangshaopeng@talkweb.com.cn
 * @desccription THREAD_LOCAL 会话工具类
 * @Date 2023-01-11
 */
public class SecurityContextHolder {
    private static final ThreadLocal<UserSessionVO> THREAD_LOCAL = new ThreadLocal<>();

    public static void set(UserSessionVO userSessionVO) {
        THREAD_LOCAL.set(userSessionVO);
    }

    public static Long getTenantId() {
        return THREAD_LOCAL.get().getTenantId();
    }

    public static Long getUserId() {
        return THREAD_LOCAL.get().getUserId();
    }

    public static List<Long> getOrgIds() {
        return THREAD_LOCAL.get().getOrgIds();
    }

    public static void remove() {
        THREAD_LOCAL.remove();
    }
}
